#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;

struct Jungle {
	int dis, fuel;
};

bool operator<(const Jungle& a, const Jungle& b)
{
	return (a.dis < b.dis);
}

int main()
{
	int n, l, p;
	cin >> n;
	Jungle da[n+1];
	for (int i = 0; i < n; ++i) cin >> da[i].dis >> da[i].fuel;
	cin >> l >> p;
	for (int i = 0; i < n; ++i) da[i].dis = l - da[i].dis;
	sort(da, da + n);
	da[n].dis = l; da[n].fuel = 0;
	priority_queue<int> que;
	int ans = 0;
	for (int i = 0; i <= n; ++i) {
		if (p >= da[i].dis)
			que.push(da[i].fuel);
		else {
			do {
				if (que.empty()) {
					cout << -1 << endl;
					return 0;
				}
				p += que.top();
				que.pop();
				++ans;
			} while (p < da[i].dis);
			que.push(da[i].fuel);
		}
	}
	cout << ans << endl;
	return 0;
}
